package new_cate_service

import (
	"shop/internal/models"
	"shop/internal/models/vo"
)

type NewCate struct {
	Id      int64
	Name    string
	Enabled int
	M       *models.NewCategory
	Ids     []int64
}

type GetNewCateAlls struct {
}

func (d *NewCate) GetNewCateAll() vo.ResultList {
	maps := make(map[string]interface{})
	maps["is_del"] = 0
	if d.Enabled >= 0 {
		maps["is_show"] = d.Enabled
	}
	if d.Name != "" {
		maps["name"] = d.Name
	}
	list := models.GetNewAllCates(maps)
	return vo.ResultList{Content: list, TotalElements: 0}
}

func (d *NewCate) Insert() error {
	return models.AddNewCate(d.M)
}

func (d *NewCate) Save() error {
	return models.UpdateNewCate(d.M)
}

func (d *NewCate) Delete() error {
	return models.DelNewcate(d.Ids)
}
